//===- FIRTokenKinds.def - .fir file Token Descriptions ---------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is intended to be #include'd multiple times to extract information
// about tokens for various clients in the lexer.
//
//===----------------------------------------------------------------------===//

#if !defined(TOK_MARKER) && !defined(TOK_IDENTIFIER) &&                        \
    !defined(TOK_LITERAL) && !defined(TOK_PUNCTUATION) &&                      \
    !defined(TOK_KEYWORD) && !defined(TOK_LPKEYWORD) &&                        \
    !defined(TOK_LPKEYWORD_PRIM)
#error Must define one of the TOK_ macros.
#endif

#ifndef TOK_MARKER
#define TOK_MARKER(X)
#endif
#ifndef TOK_IDENTIFIER
#define TOK_IDENTIFIER(NAME)
#endif
#ifndef TOK_LITERAL
#define TOK_LITERAL(NAME)
#endif
#ifndef TOK_PUNCTUATION
#define TOK_PUNCTUATION(NAME, SPELLING)
#endif
#ifndef TOK_KEYWORD
#define TOK_KEYWORD(SPELLING)
#endif
#ifndef TOK_LPKEYWORD
#define TOK_LPKEYWORD(SPELLING)
#endif
#ifndef TOK_LPKEYWORD_PRIM
#define TOK_LPKEYWORD_PRIM(SPELLING, CLASS, NUMOPERANDS, NUMATTRIBUTES,        \
                           VERSION, FEATURE)                                   \
  TOK_LPKEYWORD(SPELLING)
#endif

// Markers
TOK_MARKER(eof)
TOK_MARKER(error)

// Identifiers.
TOK_IDENTIFIER(identifier)         // foo
TOK_IDENTIFIER(literal_identifier) // `42`

// Literals
TOK_LITERAL(integer)                 // 42
TOK_LITERAL(signed_integer)          // -42 and +42
TOK_LITERAL(radix_specified_integer) // 0b101010, 0o52, 0d42, 0h2a and negations
TOK_LITERAL(floatingpoint)           // 42.0
TOK_LITERAL(version)                 // 1.2.3
TOK_LITERAL(string)                  // "foo"
TOK_LITERAL(verbatim_string)         // 'foo'

TOK_LITERAL(fileinfo)
TOK_LITERAL(inlineannotation) // %[{"foo":"bar"}]

// Punctuation.
TOK_PUNCTUATION(period, ".")
TOK_PUNCTUATION(comma, ",")
TOK_PUNCTUATION(colon, ":")
TOK_PUNCTUATION(question, "?")
TOK_PUNCTUATION(l_paren, "(")
TOK_PUNCTUATION(r_paren, ")")
TOK_PUNCTUATION(l_brace, "{")
TOK_PUNCTUATION(l_brace_bar, "{|")
TOK_PUNCTUATION(r_brace, "}")
TOK_PUNCTUATION(r_brace_bar, "|}")
TOK_PUNCTUATION(l_square, "[")
TOK_PUNCTUATION(r_square, "]")
TOK_PUNCTUATION(less, "<")
TOK_PUNCTUATION(less_equal, "<=")
TOK_PUNCTUATION(greater, ">")
TOK_PUNCTUATION(equal, "=")
TOK_PUNCTUATION(equal_greater, "=>")

// Keywords.  These turn "foo" into FIRToken::kw_foo enums.

// NOTE: Please key these alphabetized to make it easier to find something in
// this list and to cater to OCD.
TOK_KEYWORD(Analog)
TOK_KEYWORD(AnyRef)
TOK_KEYWORD(AsyncReset)
TOK_KEYWORD(Bool)
TOK_KEYWORD(Clock)
TOK_KEYWORD(Domain)
TOK_KEYWORD(Double)
TOK_KEYWORD(FIRRTL)
TOK_KEYWORD(Fixed)
TOK_KEYWORD(Inst)
TOK_KEYWORD(Integer)
TOK_KEYWORD(List)
TOK_KEYWORD(Path)
TOK_KEYWORD(Probe)
TOK_KEYWORD(RWProbe)
TOK_KEYWORD(Reset)
TOK_KEYWORD(SInt)
TOK_KEYWORD(String)
TOK_KEYWORD(UInt)
TOK_KEYWORD(attach)
TOK_KEYWORD(case)
TOK_KEYWORD(circuit)
TOK_KEYWORD(class)
TOK_KEYWORD(cmem)
TOK_KEYWORD(connect)
TOK_KEYWORD(const)
TOK_KEYWORD(contract)
TOK_KEYWORD(declgroup)
TOK_KEYWORD(define)
TOK_KEYWORD(defname)
TOK_KEYWORD(domain)
TOK_KEYWORD(domain_define)
TOK_KEYWORD(domains)
TOK_KEYWORD(else)
TOK_KEYWORD(enablelayer)
TOK_KEYWORD(knownlayer)
TOK_KEYWORD(extclass)
TOK_KEYWORD(extmodule)
TOK_KEYWORD(false)
TOK_KEYWORD(flip)
TOK_KEYWORD(formal)
TOK_KEYWORD(group)
TOK_KEYWORD(infer)
TOK_KEYWORD(input)
TOK_KEYWORD(inst)
TOK_KEYWORD(instchoice)
TOK_KEYWORD(intmodule)
TOK_KEYWORD(intrinsic)
TOK_KEYWORD(invalid)
TOK_KEYWORD(invalidate)
TOK_KEYWORD(is)
TOK_KEYWORD(layer)
TOK_KEYWORD(layerblock)
TOK_KEYWORD(match)
TOK_KEYWORD(mem)
TOK_KEYWORD(module)
TOK_KEYWORD(mport)
TOK_KEYWORD(new)
TOK_KEYWORD(node)
TOK_KEYWORD(object)
TOK_KEYWORD(of)
TOK_KEYWORD(old)
TOK_KEYWORD(option)
TOK_KEYWORD(output)
TOK_KEYWORD(parameter)
TOK_KEYWORD(propassign)
TOK_KEYWORD(public)
TOK_KEYWORD(rdwr)
TOK_KEYWORD(read)
TOK_KEYWORD(ref)
TOK_KEYWORD(reg)
TOK_KEYWORD(regreset)
TOK_KEYWORD(reset)
TOK_KEYWORD(simulation)
TOK_KEYWORD(skip)
TOK_KEYWORD(smem)
TOK_KEYWORD(symbolic)
TOK_KEYWORD(true)
TOK_KEYWORD(type)
TOK_KEYWORD(undefined)
TOK_KEYWORD(version)
TOK_KEYWORD(when)
TOK_KEYWORD(wire)
TOK_KEYWORD(with)
TOK_KEYWORD(write)

// Keywords when followed by an '('.  These turn "foo" into
// FIRToken::lp_foo enums.
TOK_LPKEYWORD(printf)
TOK_LPKEYWORD(fprintf)
TOK_LPKEYWORD(fflush)
TOK_LPKEYWORD(stop)
TOK_LPKEYWORD(assert)
TOK_LPKEYWORD(assume)
TOK_LPKEYWORD(cover)

TOK_LPKEYWORD(path)
TOK_LPKEYWORD(list_concat)

TOK_LPKEYWORD(force)
TOK_LPKEYWORD(force_initial)
TOK_LPKEYWORD(release)
TOK_LPKEYWORD(release_initial)

TOK_LPKEYWORD(read)
TOK_LPKEYWORD(probe)
TOK_LPKEYWORD(rwprobe)

TOK_LPKEYWORD(intrinsic)
TOK_LPKEYWORD(cat)
TOK_LPKEYWORD(unsafe_domain_cast)

// These are for LPKEYWORD cases that correspond to a primitive operation.
TOK_LPKEYWORD_PRIM(add, AddPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(and, AndPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(andr, AndRPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(asAsyncReset, AsAsyncResetPrimOp, 1, 0, FIRVersion(0, 0, 0),
                   "Base")
TOK_LPKEYWORD_PRIM(asClock, AsClockPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(asSInt, AsSIntPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(asUInt, AsUIntPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(bits, BitsPrimOp, 1, 2, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(cvt, CvtPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(div, DivPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(dshl, DShlPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(dshlw, DShlwPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(dshr, DShrPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(eq, EQPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(geq, GEQPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(gt, GTPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(head, HeadPrimOp, 1, 1, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(leq, LEQPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(lt, LTPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(mul, MulPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(mux, MuxPrimOp, 3, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(neg, NegPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(neq, NEQPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(not, NotPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(or, OrPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(orr, OrRPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(pad, PadPrimOp, 1, 1, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(rem, RemPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(shl, ShlPrimOp, 1, 1, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(shr, ShrPrimOp, 1, 1, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(sub, SubPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(tagExtract, TagExtractOp, 1, 0, missingSpecFIRVersion, "Enumerations")
TOK_LPKEYWORD_PRIM(tail, TailPrimOp, 1, 1, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(xor, XorPrimOp, 2, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(xorr, XorRPrimOp, 1, 0, FIRVersion(0, 0, 0), "Base")
TOK_LPKEYWORD_PRIM(integer_add, IntegerAddOp, 2, 0, FIRVersion(3, 1, 0),
                   "Integers")
TOK_LPKEYWORD_PRIM(integer_mul, IntegerMulOp, 2, 0, FIRVersion(3, 1, 0),
                   "Integers")
TOK_LPKEYWORD_PRIM(integer_shr, IntegerShrOp, 2, 0, FIRVersion(3, 1, 0),
                   "Integers")
TOK_LPKEYWORD_PRIM(integer_shl, IntegerShlOp, 2, 0, FIRVersion(3, 1, 0),
                   "Integers")

#undef TOK_MARKER
#undef TOK_IDENTIFIER
#undef TOK_LITERAL
#undef TOK_PUNCTUATION
#undef TOK_KEYWORD
#undef TOK_LPKEYWORD
#undef TOK_LPKEYWORD_PRIM
